package org.example.bookingsystem.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface BankMapper {
    @Update("UPDATE bank b " +
            "SET b.balance = b.balance - (" +
            "    SELECT t.cost " +
            "    FROM ticketList t " +
            "    WHERE t.tid = #{tid}" +
            ") " +
            "WHERE b.uid = #{uid}")
    public int updateBalance(int uid,int tid);

    @Select("select balance from bank where uid = #{uid}")
    public int getBalance(int uid);
}
